<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 CalenderUI();
 link_js(array('jquery.fixedheader','bootstrap-typeahead'),'asset/js/');
 ?>
<!--<div class='container'>-->
     <div class="tabbable"> <!-- Only required for left/right tabs -->
	<?=$tab_header;?>
       <div class="tab-content" style='height:450px;'>
	   <br>
            <div class="tab-pane active" id="table1"><?=$this->zetro_auth->allAuth($form,'setoran_tunai');?></div>
       </div>
		<input type='hidden' id='row_aktif' value='<?=empty($_GET['p'])?'':$_GET['p'];?>'/>
		<input type='hidden' id='rows' value='<?=base64_decode($this->session->userdata('menus'));?>'/>
    </div>
<!--</div>-->
<script language='javascript'>
$(document).ready(function(e) {
	$('div.tab-content').css('height',(screen.availHeight-275));
	$('#tp_simpanan').html("<?=$simp;?>");
	$('#tp_setoran').val('Simpanan').select();
	_get_member('D');_get_member('R');
	($('#row_aktif').val()=='y')?$('li#t-table2').hide():$('li#t-table2').show();
	 $('#tgl_trans').datepicker();
	 $('#tgl_trans').datepicker("option","dateFormat","dd/mm/yy");
	 /*$('#tgl_trans').datepicker({minDate:-30,maxDate:"+0Y"})*/;
	 tglNow('#tgl_trans');
		formatAngka('jml_simpanan');
		formatAngka('saldo_pinjaman');
		$('#no_member').change(function(){_get_detail($(this).val());});
		$('#nm_member').live('change',function(){_get_detail($(this).val());});
		$('#tp_simpanan').change(function()
		{
			($('#no_member').val()!='')?
			_get_saldo_simpanan($('#no_member').val(),$(this).val()):
			jAlert('Nama Anggota / Nomor Anggota belum di isi','Ziebar Alert');
		})
		 /*$('#d_Save').click(function(){})*/;
		 $('#b_Save').click(function(){($('#kd_akun').val().length>=5)?_simpan_data():jAlert('Kode Akun belum sesuai');});
})

function _get_member(tp)
{
	$.post('getakunmember',{'st':tp},function(result){
		(tp=='R')?$('#no_member').typeahead({source:$.parseJSON(result)}):
		$('#nm_member').typeahead({source:$.parseJSON(result)});});
}
function _get_detail(fld)
{
	$.post('get_akun_detail',{'id':fld},function(result)
	{
		var r=$.parseJSON(result);
		$('#nm_member').val(r.nm_member);
		$('#no_member').val(r.id_reg);
		})
}
function _simpan_data(){
	if($('#frm1').validationEngine('validate')){
		$.post('set_setoran',$('#frm1').serialize(),function(result)
		{
			$('#result').html(result).show().fadeOut(5000);
			$('#d_Save').click();tglNow('#tgl_trans');
		})
	}
}
function _get_saldo_simpanan(id,tp)
{
	switch(tp)
	{
		case '4':fld="saldo_pinjaman_barang";break;
		case '5':fld="saldo_pinjaman_uang";break;
		case '6':fld="saldo_pinj_nonkredit";break;
	}
	$.post('getsaldosimpanan',{'id_member':id,'fld':fld},
	function(result)
	{
		$('#saldo_pinjaman').attr('readonly','readonly').val(result).priceFormat();
		_get_angsuran(id,tp);
	})
}

function _get_angsuran(id,id_pinj)
{
	$.post('getjmlangsuran',{'id':id,'tp':id_pinj},
	function(result)
	{
		var r=$.parseJSON(result);
		$('#jml_cicilan').val(r.pokok).priceFormat();
		$('#jml_cicilan_bunga').val(r.bunga).priceFormat();	
	})
}
</script>
<? //link_js(array('setoran'),'application/zetro_js/');?>